#include "list.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct list *
create_list(struct list *head, const void *value, int size)
{
    if ((head = (struct list *)malloc(sizeof(struct list))) != NULL)
    {
       head->next = NULL;
    }


    if ((head->value = calloc(size + 1, sizeof(char))) == NULL)
    {
        free(head);
        return (NULL);
    }
    
    memmove(head->value, value, size);
    return (head);
}

void
destroy_list(struct list *head)
{
    while (head != NULL)
    {
        struct list *free_list = NULL;
        free_list = head;
        head = head->next;
        if (free_list->value != NULL)
        {
            free(free_list->value);
            free_list->value = NULL;
        }
        free(free_list);
        free_list = NULL;
    }
}
